package com.hqyj.sale.service.impl;

import com.hqyj.repertory.mapper.OutRepertoryMapper;
import com.hqyj.repertory.mapper.RepertoryMapper;
import com.hqyj.sale.mapper.SaleInfoMapper;
import com.hqyj.sale.model.SaleInfo;
import com.hqyj.sale.service.SaleInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;

/**
 * @author cz
 * 2021/9/6 9:28
 */
@Service
public class SaleInfoServiceImpl implements SaleInfoService {

    @Autowired
    private SaleInfoMapper saleInfoMapper;

    @Autowired
    private OutRepertoryMapper outRepertoryMapper;

    @Override
    public List<SaleInfo> queryAllSaleInfo() {
        return saleInfoMapper.queryAllSaleInfo();
    }

    @Override
    public int updateSaleInfoBySaleInfo(SaleInfo saleInfo){
        return saleInfoMapper.updateByPrimaryKeySelective(saleInfo);
    }

    @Override
    public int addSaleInfoBySaleInfo(SaleInfo saleInfo) {

        return saleInfoMapper.insertSelective(saleInfo);
    }

    @Override
    public int updateSaleInfoById(int id) {
        return saleInfoMapper.updateSaleInfoById(id);
    }

    @Override
    public SaleInfo querySaleInfoById(int id) {
        return saleInfoMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<SaleInfo> queryAllSaleInfoBySended() {
        return saleInfoMapper.queryAllSaleInfoBySended();
    }

    @Override
    public int deleteSaleInfoById(int id) {
        return saleInfoMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insertOutRepertoryByProductInfo(String productName, Integer saleAmount, String type) {
        return outRepertoryMapper.insertOutRepertoryByProductInfo(productName,saleAmount,type);
    }
}
